/***************************************************************
 * Name:      keytables.h
 * Purpose:   Code for SketchUp Ruby Extension EventRelay
 * Author:    pecan Heber
 * Created:   2008/10/21
 * Copyright: pecan Heber
 * License:   GPL
 **************************************************************/
/*
	This file is part of Eventrelay, a Ruby extension for SketchUp
	Copyright (C) 2008,2009 Pecan Heber

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
// ----------------------------------------------------------------------------
//  keytables.h
// ----------------------------------------------------------------------------
// RCS-ID: $Id: keytables.h 15 2007-01-14 05:32:30Z Pecan $

#ifndef KEYTABLES_H
#define KEYTABLES_H

#include <wx/arrstr.h>
#include <wx/dynarray.h>

#if defined (__WXGTK__) || defined (__WXMAC__)
    #include <X11/X.h>
#endif

const bool OFF	= false;
const bool ON   = true;
const bool SHIFT_DOWN = true;
const bool SHIFT_UP   = false;
const int  VKB_KEYSYM = 0;
const int  USR_KEYSYM = 1;
const int  VK_MOUSESYM = 3;

// one time key press modifiers such as !^+ (alt, ctrl, shift)
const unsigned NO_FLAGS             =   0;
const unsigned SEND_ALT_FLAG	    =   1;
const unsigned SEND_SHIFT_FLAG	    =   2;
const unsigned SEND_CTRL_FLAG	    =   4;
// stickey key modifiers such as {ALTDOWN} {SHIFTDOWN} {CTRLDOWN}
const unsigned ALT_DOWN_FLAG	    =   8;
const unsigned SHIFT_DOWN_FLAG	    =  16;
const unsigned CTRL_DOWN_FLAG	    =  32;
// CLEAR_SEND_FLAGS contains all flags *except* SEND_xxx_FLAGs
const unsigned CLEAR_SEND_FLAGS		= ALT_DOWN_FLAG+CTRL_DOWN_FLAG+SHIFT_DOWN_FLAG;

// Named Macro keys requiring above modifier checks
typedef enum {	ALT,
                CTRLDOWN,
                CTRLUP,
                ALTDOWN,
                ALTUP,
                SHIFTDOWN,
                SHIFTUP,
				NUMPADENTER,
				ASC,
				WAIT
} NamedMacroKeys;

//  missing mingw header definitions
    #define MAPVK_VK_TO_VSC     0

// ----------------------------------------------------------------------------
class KeyTables : public wxArrayString
// ----------------------------------------------------------------------------
{
    public:
        KeyTables();
       ~KeyTables();

       wxArrayString wsMacTable;
       wxArrayInt    wnMacType;
       wxArrayInt    wnKeyCode;
       wxArrayInt    wnExtendedKeys;
       int           m_KeyTableEntryCount;

       #if defined (__WXGTK__) || defined (__WXMAC__)
        static KeySym KSToUpper[26];
       #endif

       const wxArrayString* GetpNameMacroKeyTable() {return &wsMacTable;}
       wxString GetKeySymFromVKey(UINT vkey)
            {   int i = 0;
                if ( (i = wnKeyCode.Index(vkey)) == wxNOT_FOUND)
                    return wxEmptyString;
                else return wsMacTable.Item(i);
            ;}
};

extern KeyTables keyTables;
#if defined (__WXGTK__) || defined (__WXMAC__)
extern struct charToKeysymTable {char from; KeySym to;} CtoKSTable[];
#endif

#endif // KEYTABLES_H
